<template>
	<view class="body">
		<xk-header title="维修记录"></xk-header>
		<view class="list" >
			<view class="list-item header" @click="orderMore = !orderMore">
				<view>报修单号:  {{data.apply_no}}</view>
				<image v-if="!orderMore" src="/static/up.png"></image>
				<image v-else  src="/static/down.png"></image>
			</view>
			<view v-if="orderMore" class="data-item">
				<view class="order-info">
					<view class="info-item"><view class="key">报修人：</view>{{data.apply_user }}</view>
					<view class="info-item"><view class="key">业主单位：</view>{{data.apply_company_name || '暂无'}}</view>
					<view class="info-item"><view class="key">物业编号：</view>{{data.property_code || '暂无'}}</view>
					<view class="info-item"><view class="key">报修设施：</view>{{data.buliding_no + data.storey_no + (data.repair_Address||"")}}</view>
					<view class="info-item"><view class="key">预约上门时间：</view>{{data.plan_date || data.appointment_time}}</view>
					<view class="info-item"><view class="key">报修描述：</view><text>{{data.repair_content}}</text></view>
					<!-- <view class="info-item error"><view class="key">异常记录：</view>墙壁表层脱落</view> -->
					<view v-if="data.repair_image" class="info-item"><view class="key"></view>
						<image-list :pics="data.repair_image"></image-list>
					</view>
				</view>
			</view>
		</view>

		<view class="list" >
			<view class="list-item header" @click="more = !more">
				<view>维修记录</view>
				<image v-if="!more" src="/static/up.png"></image>
				<image v-else  src="/static/down.png"></image>
			</view>
			<view v-if="more" class="data-item">
				<view class="order-info">
					<view class="info-item"><view class="key">接单人：</view>{{data.receiver}}</view>
					<view class="info-item"><view class="key">维修类型：</view>{{data.repair_type_nametwo}}</view>
					<view class="info-item"><view class="key">维修时间：</view>{{data.finish_time}}</view>
					<view @click="editMate" class="info-item" style="justify-content: space-between;">
						<view class="key">物料领用：</view>
						<view style="display: flex; align-items: center;">
							<text  v-if="data.materials.length > 0" class="right-title1" style="color: #2C72FF;">已添加{{data.materials.length}}种物料</text>
							<text v-else class="right-title1" style="color: #2C72FF;">查看明细</text>
							<image mode="aspectFill" class="jiantou" src="/static/jiantou.png"/>
						</view>
					</view>
					<view class="info-item"><view class="key">工作时长(小时)：</view>{{data.work_time}}</view>
					<view class="info-item"><view class="key">结算金额(元)：</view>{{data.repair_money}}</view>
					<view class="info-item"><view class="key">支付方：</view>{{data.payer_str}}</view>
					<view class="info-item"><view class="key">维修描述：</view><text>{{data.record_remark}}</text></view>
					<!-- <view class="info-item error"><view class="key">异常记录：</view>墙壁表层脱落</view> -->
					<view v-if="data.record_image" class="info-item"><view class="key"></view>
						<image-list :pics="data.record_image"></image-list>
					</view>
				</view>
			</view>
		</view>

		<view class="common-bottom-view">
			<view class="common-btn" @click="back">返回</view>
		</view>
		<view class="common-zw"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				repairId: '',
				data: {
					materials: []
				},
				backMore: false,
				more: true,
				orderMore: true,
			};
		},
		onLoad(options) {
			this.repairId = options.repairId
			this.getServiceRepairData();
		},
		methods:{
			getServiceRepairData(){
				this.$api.baseData_getPmServiceRepair(this.repairId).then((res)=>{
					this.data = res.pmServiceRepair
					this.initInfo()
				})
			},
			initInfo() {
				this.$api.baseData_getToolDataList({
					code: "PM_SERVICE_REPAIR_PAYER" + "_nostr"
				}).then(res => {
					for (let item of res) {
						if(item.data_value == this.data.payer){
							this.data = Object.assign({}, this.data, {payer_str: item.data_text})
							break;
						}
					}
				})
				// this.$api.baseData_getBaseRepairType().then(res => {
				// 	for (let item of res) {
				// 		if(item.type_id == this.data.repair_type_idtwo){
				// 			this.data = Object.assign({}, this.data, {repair_type_str: item.type_name})
				// 			break;
				// 		}
				// 	}
				// })
			},
			editMate(){
				uni.navigateTo({
					url: '/pagesA/facility-repair/facility-repair-material?type=view&mateList=' + JSON.stringify(this.data.materials)
				})
			},
			back(){
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss" scoped>
@import '@/common/from.scss';
</style>
